package com.wd.tech.view.activity;


import android.content.Intent;
import android.os.Bundle;
import android.view.View;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.wd.tech.R;
import com.wd.tech.bean.PlateBean;
import com.wd.tech.mvp.base.BaseActivity;
import com.wd.tech.mvp.base.BasePresenter;
import com.wd.tech.mvp.presenter.PresenterImpl;
import com.wd.tech.mvp.util.MyUrl;
import com.wd.tech.view.adapter.PlateAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;


//所有模块Activity
public class PlateActivity extends BaseActivity implements View.OnClickListener {


    @BindView(R.id.xrv_plate)
    RecyclerView xrvPlate;
    ArrayList<PlateBean.ResultBean>list=new ArrayList<>();
    private int stateTechId;
    private String name1;

    @Override
    protected void startCoding() {
        mPresenter.startgetInfo(MyUrl.suoyoubankuai, PlateBean.class);
        stateTechId=getIntent().getIntExtra("id",0);
        name1=getIntent().getStringExtra("techName");


    }

    @Override
    protected BasePresenter initPresenter() {
        return new PresenterImpl();
    }

    @Override
    protected void initView() {
        //设置布局管理器
        xrvPlate.setLayoutManager(new GridLayoutManager(getApplication(), 2));
    }

    @Override
    protected int Layout() {
        return R.layout.activity_pleate;
    }

    @Override
    public void onClick(View v) {

    }

    @Override
    public void onSuccess(Object o) {
        if (o instanceof PlateBean) {
            List<PlateBean.ResultBean> result = ((PlateBean) o).getResult();
            list.addAll(result);
            PlateAdapter plateAdapter = new PlateAdapter(this,list);
            xrvPlate.setAdapter(plateAdapter);

            plateAdapter.setOnClick(new PlateAdapter.onItemClick() {
                @Override
                public void setonItemClick(String techName,int id) {
                    Intent intent=new Intent(PlateActivity.this,PlateLieBiaoActivity.class);
                    intent.putExtra("techName",techName);
                    intent.putExtra("id",id);

                    startActivity(intent);

                }
            });

        }

    }

    @Override
    public void onError(String error) {

    }



}
